<!-- 管理员用户组新增和编辑页面 -->
<extend name="Public/base"/>
<block name="body">
    <div class="main-title">
        <h2>{:L("_IDENTITY_USERS_CAN_HAVE_A_LABEL_CONFIGURATION_")}</h2>
    </div>
    <div class="tab-wrap with-padding">

        <div class="clearfix">
            <div class="col-xs-10">
                <include file="_link"/>
            </div>
            <div class="col-xs-2 text-right">
                <select name="role" class="form-control">
                    <volist name="role_list" id="vo">
                        <option value="{:U('Role/configUserTag',array('id'=>$vo['id']))}"
                        <eq name="vo['id']" value="$this_role['id']">selected</eq>
                        >{$vo.title}</option>
                    </volist>
                </select>
            </div>
        </div>

        <div>
            <!-- 访问授权 -->
            <div class="node-list in">
                <form action="__SELF__" enctype="application/x-www-form-urlencoded" method="POST" class="form-horizontal auth-form">
                    <notempty name="tag_list">
                        <volist name="tag_list" id="tag_group">
                            <dl class="checkmod">
                                <dt class="hd">
                                    <label class="checkbox"><input class="auth_fields fields_all" type="checkbox">{$tag_group.title}</label>
                                </dt>
                                <dd class="bd">
                                    <present name="tag_group['tag_list']">
                                        <volist name="tag_group['tag_list']" id="tag">
                                            <div class="filed_check">
                                                <div>
                                                    <label class="checkbox">
                                                        <input class="auth_fields fields_row" type="checkbox" name="tags[]" value="{$tag.id}"/>【{$tag.id}】{$tag.title}
                                                    </label>
                                                </div>
                                            </div>
                                        </volist>
                                    </present>
                                    <div class="clearfix"></div>
                                </dd>
                            </dl>
                        </volist>
                        <else/>
                        <div style="margin: 10px;color: rgb(255, 81, 81);">{:L("_FIRST_PLEASE_GO_TO_THE_USER_THE_USER_LABEL_MANAGEMENT_TAB_LIST_WITH_SPACE_")}中<a href="{:U('Admin/UserTag/userTag')}" title="" target="_blank" style="color: rgb(255, 81, 81);text-decoration: underline;">{:L("_ADD_USER_TAGS_")}</a>~</div>
                    </notempty>

                    <input type="hidden" name="id" value="{$this_role.id}"/>
                    <button type="submit" class="btn submit-btn ajax-post" target-form="auth-form">{:L("_SURE_WITH_SPACE_")}</button>
                    <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">{:L("_RETURN_WITH_SPACE_")}</button>
                    <span style="color: #BABABA;margin: 11px;">{:L("_PLEASE_SAVE_THE_ABOVE_CONFIGURATION_AND_THEN_SWITCH_TO_ANOTHER_INTERFACE_")}</span>
                </form>
            </div>

            <!-- 成员授权 -->
            <div class="tab-pane"></div>

            <!-- 分类 -->
            <div class="tab-pane"></div>
        </div>
    </div>
    <style>
        .filed_check {
            width: 200px;
            float: left;
            margin: 5px 0;
        }
    </style>
</block>
<block name="script">
    <script type="text/javascript" src="__STATIC__/qtip/jquery.qtip.min.js"></script>
    <link rel="stylesheet" type="text/css" href="__STATIC__/qtip/jquery.qtip.min.css" media="all">
    <script type="text/javascript" charset="utf-8">
        +function ($) {
            var fields = [{$this_role.fields}];
        $('.auth_fields').each(function () {
            if ($.inArray(parseInt(this.value, 10), fields) > -1) {
                $(this).prop('checked', true);
            }
            if (this.value == '') {
                $(this).closest('span').remove();
            }
        });

        //全选节点
        $('.fields_all').on('change', function () {
            $(this).closest('dl').find('dd').find('input').prop('checked', this.checked);
        });
        $('.fields_row').on('change', function () {
            $(this).closest('.filed_check').find('.child_row').find('input').prop('checked', this.checked);
        });

        $('.checkbox').each(function () {
            $(this).qtip({
                content: {
                    text: $(this).attr('title'),
                    title: $(this).text()
                },
                position: {
                    my: 'bottom center',
                    at: 'top center',
                    target: $(this)
                },
                style: {
                    classes: 'qtip-dark',
                    tip: {
                        corner: true,
                        mimic: false,
                        width: 10,
                        height: 10
                    }
                }
            });
        });

        $('select[name="role"]').change(function () {
            location.href = this.value;
        });
        //导航高亮
        highlight_subnav('{:U('Role/configusertag')}');
        }(jQuery);
    </script>
</block>
